home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 742 / rkrm_lib2 / rkrm_lib2.lha / Exec_Library / Interrupts / rbfhandler.asm < prev    next >
Assembly Source File  |  1992-09-03  |  4KB  |  95 lines

  1. * rbfhandler.asm. Example interrupt handler for rbf.
  2. *
  3. * Assembled with Howesoft Adapt 680x0 Macro Assembler Rel. 1.0
  4. * hx68 from: rbfhandler.asm to rbfhandler.o INCDIR include:
  5. * blink from lib:c.o rbf.o rbfhandler.o to rbf lib lib:lc.lib lib:amiga.lib
  6. *
  7. *
  8. * Copyright (c) 1992 Commodore-Amiga, Inc.
  9. *
  10. * This example is provided in electronic form by Commodore-Amiga, Inc. for
  11. * use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  12. * published by Addison-Wesley (ISBN 0-201-56774-1).
  13. *
  14. * The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  15. * information on the correct usage of the techniques and operating system
  16. * functions presented in these examples.  The source and executable code
  17. * of these examples may only be distributed in free electronic form, via
  18. * bulletin board or as part of a fully non-commercial and freely
  19. * redistributable diskette.  Both the source and executable code (including
  20. * comments) must be included, without modification, in any copy.  This
  21. * example may not be published in printed form or distributed with any
  22. * commercial product.  However, the programming techniques and support
  23. * routines set forth in these examples may be used in the development
  24. * of original executable software products for Commodore Amiga computers.
  25. *
  26. * All other rights reserved.
  27. *
  28. * This example is provided "as-is" and is subject to change; no
  29. * warranties are made.  All use is at your own risk. No liability or
  30. * responsibility is assumed.
  31.  
  32.     INCLUDE "exec/types.i"
  33.     INCLUDE "hardware/custom.i"
  34.     INCLUDE "hardware/intbits.i"
  35.  
  36.         XDEF    _RBFHandler
  37.  
  38. JSRLIB MACRO
  39.        XREF _LVO\1
  40.        JSR  _LVO\1(A6)
  41.        ENDM
  42.  
  43. BUFLEN    EQU    256
  44.  
  45.        STRUCTURE RBFDATA,0
  46.         APTR   rd_task
  47.         ULONG  rd_signal
  48.         UWORD  rd_buffercount
  49.         STRUCT rd_charbuffer,BUFLEN+2
  50.         STRUCT rd_flagbuffer,BUFLEN+2
  51.         STRUCT rd_name,32
  52.         LABEL RBFDATA_SIZEOF
  53.  
  54. * Entered with:
  55. *  D0 == scratch
  56. *  D1 == INTENAT & INTREQR (scratch)
  57. *  A0 == custom chips (scratch)
  58. *  A1 == is_Data which is RBFDATA structure (scratch)
  59. *  A5 == vector to our code (scratch)
  60. *  A6 == pointer to ExecBase (scratch)
  61. *
  62. * Note - This simple handler just receives one buffer full of serial
  63. * input data, signals main, then ignores all subsequent serial data.
  64. *
  65.     section code
  66.  
  67. _RBFHandler:                            ;entry to our interrupt handler
  68.  
  69.         MOVE.W  serdatr(A0),D1          ;get the input word (flags and char)
  70.  
  71.         MOVE.W  rd_buffercount(A1),D0   ;get our buffer index
  72.         CMPI.W  #BUFLEN,D0              ;no more room in our buffer ?
  73.         BEQ.S   ExitHandler             ;yes - just exit (ignore new char)
  74.         LEA.L   rd_charbuffer(A1),A5    ;else get our character buffer address
  75.         MOVE.B  D1,0(A5,D0.W)           ;store character in our character buffer
  76.         LEA.L   rd_flagbuffer(A1),A5    ;get our flag buffer address
  77.         LSR.W   #8,d1                   ;shift flags down
  78.         MOVE.B  D1,0(A5,D0.W)           ;store flags in flagbuffer
  79.  
  80.         ADDQ.W  #1,D0                   ;increment our buffer index
  81.         MOVE.W  D0,rd_buffercount(A1)   ;   and replace it
  82.         CMPI.W  #BUFLEN,D0              ;did our buffer just become full ?
  83.         BNE.S   ExitHandler             ;no - we can exit
  84.         MOVE.L  A0,-(SP)                ;yes - save custom
  85.         MOVE.L  rd_signal(A1),D0        ;get signal allocated in main()
  86.         MOVE.L  rd_task(A1),A1          ;and pointer to main task
  87.         JSRLIB  Signal                  ;tell main we are full
  88.         MOVE.L  (SP)+,A0                ;restore custom
  89.                                         ;Note: system call trashed D0-D1/A0-A1
  90. ExitHandler:
  91.         MOVE.W  #INTF_RBF,intreq(A0)    ;clear the interrupt
  92.         RTS                             ;return to exec
  93.  
  94.         END
  95.